'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 7_llm_with_fall_back.py
* @Time: 2025/10/24
* @All Rights Reserve By Brtc
'''
import dotenv
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

dotenv.load_dotenv()

prompt = ChatPromptTemplate.from_template("{query}")
llm = ChatOpenAI(model="gpt-10000").with_fallbacks([ChatOpenAI(model="gpt-00")])

# 1、构建链应用
chain = prompt | llm | StrOutputParser()
content = chain.invoke({"query":"你好你是？"})
print(content)
